<template>
	<view>
		<view class="yinhang">
			<view class="yinhang_left">
				
				<view class="add_yinhang" v-show="add_yinhangka" @click="add">+添加银行卡</view>
				
				<view class="yinhangka" v-show="yinhangka">
					<image src="../../static/img/yuncang/bank_logo.png" mode=""></image>
					<view class="yinhang_tit">
						<view class="yinhang_name">{{bankCard}}</view>
						<view class="yinhang_code">{{issuingBank}}</view>
					</view>
				</view>
				
			</view>
			<view class="yinhang_right">
				<image src="../../static/temp/product_particulars_arrows.png" mode="" @click="add_yinhang"></image>
			</view>
			
		</view>
		
		<view class="amountMoney">
			<view class="amountMoney_title">提现金额</view>
			<view class="amountMoney_input">
				<input type="text" placeholder="请输入提现金额" placeholder-class="#cccccc" v-model="addmoney">
			</view>
			<view class="amountMoney_bottom">
				可提现金额：<view class="amountMoney_count">{{money}}</view> 元 <view class="amountMoney_all">全部提现</view>
			</view>
		</view>
		
		<view class="loginbtn" @click="withdrawal">
			<button>立即提现</button>
		</view>
		
	</view>
</template>


<script>

	export default {
		data() {
			return {
				bankCard:"",
				issuingBank:"",
				money:"",
				addmoney:"",
				add_yinhangka:false,
				yinhangka:true
			}
		},

		onLoad() {

			this.tui.request('/app/profit/withdrawal', 'GET', {},false,false,false,).then(res => {
				console.log(res);
				if (res.errno == 0) {
					this.bankCard = res.data.bankCard
					this.issuingBank = res.data.issuingBank
					this.money = res.data.balance
				}
			})

		},
		//获取导航栏右侧的按钮事件
		onNavigationBarButtonTap(e) {
			uni.navigateTo({
				url:"/pages/distribution/withdrawalRules"
			})
		
		},
		
		
		methods: {
			add(){
				// this.yinhangka = true;
				// this.add_yinhangka = false;
				uni.navigateTo({
					url:"/pages/realName/bankCard"
				})
			},
			
			add_yinhang(){
				this.add_yinhangka = true;
				this.yinhangka = false;
			},
			
			// 提现
			withdrawal(){
				this.tui.request('/app/profit/cashOut', 'POST', {
					profit:this.addmoney
				},false,false,false,).then(res => {
					console.log(res);
					if (res.errno == 0) {
						this.bankCard = res.data.bankCard
						this.issuingBank = res.data.issuingBank
					} else {
						this.tui.toast("余额不足，请重新输入");
					}
				
				})
			}
		}
	}
</script>

<style lang='scss'>
	page{
		background-color: #FAFAFA;
	}
	.yinhang{
		background:rgba(255,255,255,1);
		display: flex;
		align-items: center;
		justify-content: space-between;
		
		.yinhang_left{
			display: flex;
			align-items: center;
			padding-top: 30upx;
			padding-bottom: 30upx;
			padding-left: 30upx;
			
			image{
				width: 70upx;
				height: 70upx;
				margin-right: 30upx;
			}
			.yinhangka{
				display: flex;
				align-items: center;
				
				
				.yinhang_tit{
					
					.yinhang_name{
						font-size:32upx;
						font-family:PingFang SC;
						font-weight:400;
						color:rgba(51,51,51,1);
					}
					.yinhang_code{
						font-size:24upx;
						font-family:PingFang SC;
						font-weight:400;
						color:rgba(153,153,153,1);
					}
					
				}
			}
			
			.add_yinhang{
				font-size:32upx;
				font-family:PingFang SC;
				font-weight:400;
				color:rgba(102,102,102,1);
				padding-top: 16upx;
				padding-bottom: 16upx;
			}
			
		}
		.yinhang_right{
			color: #999999;
			padding-right: 30upx;
			
			image{
				width: 16upx;
				height: 28upx;
				
			}
		}
	}
	.amountMoney{
		margin-top: 20upx;
		padding: 20upx;
		background:rgba(255,255,255,1);
		
		.amountMoney_input{
			font-size:36upx;
			font-family:PingFang SC;
			font-weight:500;
			/* color:rgba(204,204,204,1); */
			border-bottom: 1px solid #ccc;
			margin-top: 18upx;
			padding-bottom: 10upx;
			
			
			input{
				height: 60upx;
				line-height: 60upx;
			}
		}
		
		.amountMoney_title{
			font-size:24upx;
			font-family:PingFang SC;
			font-weight:400;
			color:rgba(153,153,153,1);
		}
		
		.amountMoney_bottom{
			padding-top: 20upx;
			display: flex;
			font-size:24upx;
			font-family:PingFang SC;
			font-weight:400;
			color:rgba(153,153,153,1);
			
			
			.amountMoney_count{
				padding-left: 10upx;
				color:#FF0000;
			}
			
			
			.amountMoney_all{
				color:#FF0000;
				padding-left: 30upx;
			}
			
		}
		
		
	}
	/* 按钮 */
	.loginbtn {
		width: 90%;
		margin: 200upx auto;
	}
	
	.loginbtn button {
		margin-top: 20rpx;
		height: 88rpx;
		width: 100%;
		line-height: 88rpx;
		color: #ffffff;
		font-size: 32rpx;
		border-radius: 44rpx;
		outline: 0;
		display: block;
		margin: 0;
		font-family: inherit;
		background: #D14798;
	}
	
	
</style>
